package com.songlanyun.modules.opus.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.songlanyun.modules.goods.entity.Goods;
import com.songlanyun.modules.goods.service.GoodsService;
import com.songlanyun.modules.opus.service.OpusGoodsService;
import com.songlanyun.modules.rabbitmq.util.SpringContextUtil;
import lombok.Data;

/**
 * 作品关联商品
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-02-24 10:42:35
 */
@Data
@TableName("yxt_opus_goods")
public class OpusGoods implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 作品id
     */
    private Long opusId;
    /**
     * 商品id
     */
    private Long goodsId;

    @TableField(exist = false)
    private Goods goods;

    public void loadGoods() {
        GoodsService service = (GoodsService) SpringContextUtil.getBean("goodsService");
        this.goods = service.getById(this.getGoodsId(), false);
    }

}
